/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tbquestion_aclient;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import model.ClientModel;
import qclient.QClient;
import tbquestion_client.form.loginForm;

/**
 *
 * @author salm
 */
public class TBQuestion_AClient {

    private static String BLLHost;
    private static int BLLPort;
    
    private static void readHost()
    {
        // NEED TABLE
        try
        {
            Properties p = new Properties();
            p.load(new FileInputStream("NetworkConfig.ini"));
            
            BLLHost = p.getProperty("BLLHost");
            BLLPort = Integer.parseInt(p.getProperty("BLLPort"));
        }
        catch (IOException ioEx)
        {
            BLLHost = "localhost";
            BLLPort = 2014;
        }
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Metal".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception ex) {
            java.util.logging.Logger.getLogger(loginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
            readHost();
            
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try
                    {
                        QClient.getInstance().initialize(BLLHost, BLLPort);
                        (new Thread(QClient.getInstance())).start();

                        ClientModel.getInstance().getForms().getLoginForm().setVisible(true);
                    }
                    catch (Exception ex) {
                        Logger.getLogger(TBQuestion_AClient.class.getName()).log(Level.SEVERE, null, ex);
                        JOptionPane.showMessageDialog(null, ex);
                    }
                }
            });
    }
}